package jjn.carl.greedy;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * @author Jjn
 * @since 2023/8/2 12:33
 */
public class LeetCode763 {
    public List<Integer> partitionLabels(String s) {
        List<Integer> parts = new ArrayList<>();
        int[] dict = new int[26];
        for (int i = 0; i < s.length(); i++) {
            dict[s.charAt(i) - 'a'] = i;
        }
        int start = 0, end = 0;
        for (int i = 0; i < s.length(); i++) {
            end = Math.max(end, dict[s.charAt(i) - 'a']);
            if (i == end) {
                parts.add(end - start + 1);
                start = end + 1;
            }
        }
        return parts;
    }
    
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            String s = scanner.nextLine();
            List<Integer> list = new LeetCode763().partitionLabels(s);
            System.out.println(list.toString());
        }
    }
}
